"use strict";(globalThis.webpackChunk_github_ui_github_ui=globalThis.webpackChunk_github_ui_github_ui||[]).push([["packages_copilot-chat_components_ModelPicker_tsx-packages_copilot-byok_providers_assets_anthr-76f86b"],{5083:(e,i,l)=>{l.d(i,{v:()=>d});var o=l(74848),a=l(21728),t=l(87448),s=l(34164),r=l(76787);let n={ProviderLogo:"ProviderLogo-module__ProviderLogo--XAQ0O"};function d(e){let i,l,d,m,c,u,p=(0,a.c)(21),{className:h,provider:g,size:y}=e,v=void 0===y?"small":y;p[0]!==g?(i=(0,r.L)(g),p[0]=g,p[1]=i):i=p[1];let b=i,x=(0,t.DP)().colorMode,f="night"===x?"dark":"day"===x?"light":"auto",_=!!b.logo.dark;p[2]!==h?(l=(0,s.$)(n.ProviderLogo,h),p[2]=h,p[3]=l):l=p[3],p[4]!==_||p[5]!==f||p[6]!==b.logo.dark?(d=_&&"dark"===f&&(0,o.jsx)("source",{srcSet:b.logo.dark}),p[4]=_,p[5]=f,p[6]=b.logo.dark,p[7]=d):d=p[7],p[8]!==_||p[9]!==f||p[10]!==b.logo.dark?(m=_&&"auto"===f&&(0,o.jsx)("source",{srcSet:b.logo.dark,media:"(prefers-color-scheme: dark)"}),p[8]=_,p[9]=f,p[10]=b.logo.dark,p[11]=m):m=p[11];let j=`${b.name} logo`;return p[12]!==b.logo.light||p[13]!==j?(c=(0,o.jsx)("img",{src:b.logo.light,alt:j,"aria-hidden":!0}),p[12]=b.logo.light,p[13]=j,p[14]=c):c=p[14],p[15]!==v||p[16]!==l||p[17]!==d||p[18]!==m||p[19]!==c?(u=(0,o.jsxs)("picture",{className:l,"data-size":v,children:[d,m,c]}),p[15]=v,p[16]=l,p[17]=d,p[18]=m,p[19]=c,p[20]=u):u=p[20],u}try{d.displayName||(d.displayName="ProviderLogo")}catch{}},12970:(e,i,l)=>{l.d(i,{z5:()=>B,Yb:()=>C,k:()=>D});var o,a=l(74848),t=l(5083),s=l(4817),r=l(77430),n=l(53419),d=l(88934),m=l(38621),c=l(73783),u=l(26108),p=l(94236),h=l(5524),g=l(57352),y=l(24990),v=l(69726),b=l(84078),x=l(15220),f=l(34164),_=l(96540),j=l(25641),k=l(73952),M=l(51213),N=l(35247),w=l(79064),P=l(2635),R=l(33592),L=l(46062);let I=["o3-mini","Gemini 2.0 Flash"],E={menuButton:"ModelPicker-module__menuButton--w_ML2",buttonName:"ModelPicker-module__buttonName--Iid1H",menuHeading:"ModelPicker-module__menuHeading--PBTLv",messageRetryButtonGroup:"ModelPicker-module__messageRetryButtonGroup--UkrjO",messageRetryDivider:"ModelPicker-module__messageRetryDivider--gIDae",messageRetryMenuButton:"ModelPicker-module__messageRetryMenuButton--rNpIr",messageRetryButton:"ModelPicker-module__messageRetryButton--DqHs5",modelNameDisabled:"ModelPicker-module__modelNameDisabled--Vhv9R",modelMetaLabel:"ModelPicker-module__modelMetaLabel--zMick",footer:"ModelPicker-module__footer--yCNLJ",loadingSpinner:"ModelPicker-module__loadingSpinner--BTsER",actionMenuOverlay:"ModelPicker-module__actionMenuOverlay--Xawta"};var F=l(79184);let A="An error occurred while updating the policy";function C({onNewThreadSelected:e,type:i="global",selectedModel:l,onModelSelected:o,disabled:t=!1}){let s=(0,R.b)(),{model:r,availableModels:m,mode:c,messages:u,currentReferences:p,selectedThreadID:h,modelsLoading:g,isWaitingOnCopilot:y,streamingMessage:v}=(0,P.Pk)(),{premiumInteractionsQuotaExceeded:b,overagesEnabled:x,plan:f}=(0,F.xR)(),j="pending"===g.state,{search:I,pathname:E}=(0,d.zy)(),A=(0,_.useRef)(!1),C=N.W.premiumRequestQuotasEnabled&&b&&!x,O=t;N.W.disableModelPickerWhileStreaming&&(O=t||y||null!==v);let[q,T]=(0,_.useState)(null),U=(0,_.useRef)(!1);function B(e){o?o(e):s.selectModel(e)}return(l||(l=r),(0,_.useEffect)(()=>{j&&s.fetchModels()},[s,j]),(0,_.useEffect)(()=>{if(!A.current&&!j&&m.length>1){let e=w.Jt.getModel(h),i=e?.id,l=m.find(e=>e.id===i&&(C||i!==L.QA))||null;(!l&&f||f!==M.UH.IndividualFree&&l?.billing?.is_premium&&b&&!x)&&(l=(0,L.fZ)(m,f,b,x)),l&&(s.selectModel(l,!0),A.current=!0)}},[m,s,r,j,x,f,b,h,C]),(0,_.useEffect)(()=>{if("immersive"!==c)return;let e=new URLSearchParams(I).get("model");if(e&&("/copilot"===E||"/copilot/"===E)){if(r.id===e||U.current||!m?.length)return;U.current=!0;let i=m?.find(i=>i.id===e);i&&(s.selectModel(i,!1),(0,n.BI)("dotcom_chat.activate",{target:"COPILOT_MODEL_LOADED_FROM_URL",mode:"immersive"}))}},[m,s,c,r?.id,E,I]),m.length<2)?null:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(D,{selectedModel:l,models:m,type:i,onModelPicked:e=>{var o,a,t,s,r,d;"global"===i&&H(l,e)||((0,n.BI)("dotcom_chat.activate",{target:"MODEL_PICKER_MODEL_SELECT",mode:"immersive",model:e.id,isUnchanged:H(l,e),type:i}),H(l,e)?B(e):(o=u,a=e,("message-retry"===i?(0,k.B)(o):o).some(e=>e.skillExecutions?.length)&&(!a.capabilities?.supports?.tool_calls||a.isThirdParty||"o1-ga"===a.capabilities.family))?T({model:e,command:{action:"requires-new-conversation",reason:"external-content"}}):(t=u,s=p,r=e,(("message-retry"===i?(0,k.B)(t):t).some(e=>e.mediaContent?.length)||s.some(e=>"image"===e.type))&&!r.capabilities?.supports?.vision)?T({model:e,command:{action:"requires-new-conversation",reason:"degraded-image-support"}}):(d=e).policy&&"enabled"!==d.policy.state?T({model:e,command:{action:"requires-policy-approval"}}):B(e))},disabled:O,variant:"invisible",plan:f??void 0}),q?.command.action==="requires-new-conversation"&&(0,a.jsx)(S,{model:q.model,reason:q.command.reason,onDismiss:()=>{(0,n.BI)("dotcom_chat.activate",{target:"MODEL_PICKER_DIALOG_REQUIRES_NEW_CONVERSATION_CANCEL",mode:"immersive",model:q.model.id,type:i}),T(null)},onSwitch:async()=>{(0,n.BI)("dotcom_chat.activate",{target:"MODEL_PICKER_DIALOG_REQUIRES_NEW_CONVERSATION_CONFIRM",mode:"immersive",model:q.model.id,type:i}),T(null),await e(),s.selectModel(q.model)}}),q?.command.action==="requires-policy-approval"&&(0,a.jsx)(G,{model:q.model,mode:c,onDismiss:()=>{(0,n.BI)("dotcom_chat.activate",{target:"MODEL_PICKER_DIALOG_POLICY_CANCEL",mode:"immersive",model:q.model.id,type:i}),T(null)},onConfirm:async()=>{await s.acceptModelPolicy(q.model),s.selectModel(q.model),(0,n.BI)("dotcom_chat.activate",{target:"MODEL_PICKER_DIALOG_POLICY_CONFIRM",mode:"immersive",model:q.model.id,type:i}),T(null)}})]})}let O=_.forwardRef(function(e,i){let{selectedModel:l,onModelPicked:o,disabled:t,...s}=e;return(0,a.jsxs)(c.A,{className:E.messageRetryButtonGroup,ref:i,children:[(0,a.jsx)(u.K,{variant:"invisible","aria-label":`Retry with ${l.displayName}`,onClick:()=>o(l),icon:m.SyncIcon,disabled:t,className:E.messageRetryButton}),(0,a.jsx)("div",{className:E.messageRetryDivider}),(0,a.jsx)(u.K,{variant:"invisible",icon:m.TriangleDownIcon,"aria-label":"Retry with\u2026",disabled:t,className:E.messageRetryMenuButton,...s})]})});function D({selectedModel:e,models:i,onModelPicked:l,type:o,disabled:t,variant:s="invisible",plan:r}){let[d,m]=(0,_.useState)(!1),c=r===M.UH.IndividualFree?(()=>{let e=new Set(i.map(e=>e.displayName));return[...i,...W.filter(i=>!e.has(i.displayName)).map(z)]})():i,u=N.W.immersiveStructuredModelPicker&&function(e){let i=e.some(e=>void 0!==e.model_picker_category)&&new Set(e.filter(e=>void 0!==e.model_picker_category).map(e=>e.model_picker_category)).size>1,l=e.some(e=>e.billing?.multiplier!==void 0)&&new Set(e.filter(e=>e.billing?.multiplier!==void 0).map(e=>e.billing?.multiplier)).size>1;return i||l}(c),{lowTier:g,midTier:y,highTier:v,base:b,preview:x,custom:f}=function(e,i){let[l,o]=e.reduce((e,i)=>(e[+!(0,L.ZL)(i)].push(i),e),[[],[]]),a=l.reduce((e,i)=>{let l=i.custom_model.owner_name;return e[l]||(e[l]=[]),e[l].push(i),e},{});return i?{lowTier:o.filter(e=>void 0!==e.model_picker_category?"lightweight"===e.model_picker_category:e.billing&&(e.billing?.multiplier<1&&e.billing?.multiplier!==0||I.includes(e.displayName))||!1),midTier:o.filter(e=>void 0!==e.model_picker_category?"versatile"===e.model_picker_category:e.billing&&(e.billing?.multiplier===1||e.billing?.multiplier===0)&&!I.includes(e.displayName)||!1),highTier:o.filter(e=>void 0!==e.model_picker_category?"powerful"===e.model_picker_category:e.billing&&e.billing?.multiplier>1||!1),base:[],preview:[],custom:a}:{lowTier:[],midTier:[],highTier:[],base:o.filter(e=>!e.preview),preview:o.filter(e=>e.preview),custom:a}}(c,u),j=new Set(c.map(e=>e.vendor)).size>1,k=c.some(e=>e.isThirdParty),w=Object.keys(f).length>0,P=(0,_.useCallback)(i=>{let l=!t&&i;m(l),l&&(0,n.BI)("dotcom_chat.activate",{target:"MODEL_PICKER_OPEN",mode:"immersive",model:e.id,type:o})},[t,e.id,o]),R=(0,_.useRef)(null),[F,A]=(0,_.useState)("down");return(0,a.jsx)("div",{ref:R,children:(0,a.jsxs)(p.W,{open:d,onOpenChange:P,children:["global"===o?(0,a.jsxs)(p.W.Button,{className:E.menuButton,variant:s??"invisible",disabled:t,children:[(0,a.jsx)("span",{className:"sr-only",children:"Model: "}),(0,a.jsx)("div",{className:E.buttonName,children:e.displayName})]}):(0,a.jsx)(p.W.Anchor,{"aria-label":"Retry with model",children:(0,a.jsx)(O,{selectedModel:e,onModelPicked:l,disabled:t})}),(0,a.jsxs)(p.W.Overlay,{width:"global"===o?"medium":"small",side:"outside-bottom",overflow:"auto",className:E.actionMenuOverlay,align:"end",onPositionChange:({position:e})=>{A(["inside-bottom","outside-bottom"].includes(e.anchorSide)?"down":"up")},children:[(0,a.jsxs)(h.l,{selectionVariant:"global"===o?"single":void 0,children:["message-retry"===o&&"down"===F&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(U,{selectedModel:e,onModelPicked:l}),(0,a.jsx)(h.l.Divider,{})]}),"global"===o&&(0,a.jsx)("div",{className:E.menuHeading,children:"Models"}),b.length>0&&(0,a.jsxs)(h.l.Group,{children:["global"!==o&&(0,a.jsx)(h.l.GroupHeading,{children:"Models"}),b.map(i=>(0,a.jsx)(B,{model:i,selected:H(e,i)&&"global"===o,onModelPicked:l,hasMultipleVendors:j,hasThirdPartyModel:k},i.id))]}),g.length>0&&(0,a.jsxs)(h.l.Group,{children:[(0,a.jsx)(h.l.GroupHeading,{children:"Fast and cost-efficient"}),g.map(i=>(0,a.jsx)(B,{model:i,selected:H(e,i)&&"global"===o,onModelPicked:l,hasMultipleVendors:j,hasThirdPartyModel:k},i.id)),(y.length>0||v.length>0)&&(0,a.jsx)(h.l.Divider,{})]}),y.length>0&&(0,a.jsxs)(h.l.Group,{children:[(0,a.jsx)(h.l.GroupHeading,{children:"Versatile and highly intelligent"}),y.map(i=>(0,a.jsx)(B,{model:i,selected:H(e,i)&&"global"===o,onModelPicked:l,hasMultipleVendors:j,hasThirdPartyModel:k},i.id)),v.length>0&&(0,a.jsx)(h.l.Divider,{})]}),v.length>0&&(0,a.jsxs)(h.l.Group,{children:[(0,a.jsx)(h.l.GroupHeading,{children:"Most powerful at complex tasks"}),v.map(i=>(0,a.jsx)(B,{model:i,selected:H(e,i)&&"global"===o,onModelPicked:l,hasMultipleVendors:j,hasThirdPartyModel:k},i.id))]}),x.length>0&&(0,a.jsxs)(h.l.Group,{children:[(0,a.jsx)(h.l.GroupHeading,{children:"Preview"}),x.map(i=>(0,a.jsx)(B,{model:i,selected:H(e,i)&&"global"===o,onModelPicked:l,hasMultipleVendors:j,hasThirdPartyModel:k},i.id))]}),w&&(0,a.jsx)(q,{customModelsByGroupName:f,children:i=>(0,a.jsx)(B,{model:i,selected:H(e,i)&&"global"===o,onModelPicked:l,hasMultipleVendors:j,hasThirdPartyModel:k},i.id)}),"message-retry"===o&&"up"===F&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.l.Divider,{}),(0,a.jsx)(U,{selectedModel:e,onModelPicked:l})]})]}),N.W.premiumRequestQuotasEnabled&&(0,a.jsx)(T,{})]})]})})}function q({customModelsByGroupName:e,children:i}){let l=Object.keys(e),o=l.length-1;return l.map((l,t)=>(0,a.jsxs)(h.l.Group,{children:[(0,a.jsx)(h.l.GroupHeading,{children:l}),(e[l]??[]).map(i),ti(e),children:[(0,a.jsx)(h.l.LeadingVisual,{children:(0,a.jsx)(m.SyncIcon,{})}),"Try again",(0,a.jsx)(h.l.Description,{variant:"block",truncate:!0,children:e.displayName})]},e.id)}function B({model:e,selected:i,onModelPicked:l,hasMultipleVendors:o,hasThirdPartyModel:t}){let{plan:s,premiumInteractionsQuotaExceeded:r,chatQuotaExceeded:n,overagesEnabled:d}=(0,F.xR)(),m=s===M.UH.IndividualFree&&n,c=e.billing?.is_premium&&s!==M.UH.IndividualFree&&r&&!d,u=s&&e.billing?.restricted_to&&!e.billing?.restricted_to.includes(s),p="upsellModel"in e&&!0===e.upsellModel,g=m||c||u||p;return(0,a.jsxs)(h.l.Item,{onSelect:()=>l(e),selected:i,disabled:!!g,children:[(o||t)&&(0,a.jsx)(h.l.LeadingVisual,{children:(0,a.jsx)(Y,{model:e})}),(0,a.jsx)("span",{className:(0,f.$)(g&&E.modelNameDisabled),children:e.displayName}),N.W.premiumRequestQuotasEnabled&&e.preview&&e.id!==L.QA&&(0,a.jsx)("span",{className:E.modelMetaLabel,children:"Preview"}),!N.W.premiumRequestQuotasEnabled&&(o||t)&&(0,a.jsx)(h.l.Description,{variant:"block",truncate:!0,children:e.vendor})]},e.id)}function S({model:e,onDismiss:i,onSwitch:l,reason:o}){return(0,a.jsxs)(y.K,{title:"Switch model",onClose:e=>"confirm"===e?l():i(),confirmButtonContent:"New conversation",confirmButtonType:"primary",children:["external-content"===o&&(0,a.jsxs)("p",{children:["The ",e.displayName," model currently doesn\u2019t support external context from ongoing conversations. Start a new conversation to chat with this model."]}),"degraded-image-support"===o&&(0,a.jsxs)("p",{children:["The ",e.displayName," model doesn\u2019t support answering questions about images. Start a new conversation without images to chat with this model."]})]})}function G({model:e,mode:i,onDismiss:l,onConfirm:o}){let[t,r]=(0,_.useState)(null),[d,m]=(0,_.useState)(!1),c=e.policy?.terms??"",u=async()=>{try{m(!0),await o(),r(null)}catch{r(A),(0,n.BI)("dotcom_chat.activate.error",{target:"ERROR_MODEL_POLICY",mode:i,message:A})}finally{m(!1)}};return(0,a.jsxs)(x.l,{width:"large",onClose:l,title:`Enable ${e.displayName}`,footerButtons:[{buttonType:"default",content:"Cancel",onClick:l},{buttonType:"primary",content:d?(0,a.jsx)(v.A,{size:"small",className:E.loadingSpinner}):"Enable",onClick:()=>void u()}],children:[t&&(0,a.jsx)(b.l,{title:"Error",variant:"critical",children:t}),(0,a.jsx)(s.To,{markdown:c})]})}function Y({model:e}){return(0,L.ZL)(e)?(0,a.jsx)(t.v,{provider:e.custom_model.provider}):e.logoURL?(0,a.jsx)(r.r,{alt:`${e.vendor} logo`,square:!0,size:18,src:e.logoURL}):(0,a.jsx)(m.CopilotIcon,{})}function H(e,i){return e.id===i.id}function z(e){let i=e.logoURL?.includes("anthropic")?"Anthropic":e.logoURL?.includes("openai")?"Azure OpenAI":e.logoURL?.includes("gemini")?"Google":"Unknown";return{...e,name:e.displayName,version:"1.0",vendor:i,model_picker_enabled:!0,hasLimitedCapabilities:!1,isThirdParty:"Azure OpenAI"!==i,capabilities:{family:"unknown",limits:{max_prompt_tokens:4096},supports:{},tokenizer:"gpt",type:"chat"},preview:e.preview??!1,billing:{...e.billing,is_premium:!0}}}let W=[{id:"o4-mini-upgrade",displayName:"o4-mini",logoURL:"/images/modules/marketplace/models/families/openai.svg",upsellModel:!0,preview:!0,billing:{multiplier:.33}},{id:"claude-3.7-sonnet-upgrade",displayName:"Claude Sonnet 3.7",logoURL:"/images/modules/marketplace/models/families/anthropic.svg",upsellModel:!0,billing:{multiplier:1}},{id:"claude-sonnet-4-upgrade",displayName:"Claude Sonnet 4",logoURL:"/images/modules/marketplace/models/families/anthropic.svg",upsellModel:!0,billing:{multiplier:1}},{id:"gemini-2.5-pro-upgrade",displayName:"Gemini 2.5 Pro",logoURL:"/images/modules/marketplace/models/families/gemini.svg",upsellModel:!0,preview:!0,billing:{multiplier:1}},{id:"o3-upgrade",displayName:"o3",logoURL:"/images/modules/marketplace/models/families/openai.svg",upsellModel:!0,preview:!0,billing:{multiplier:1}},{id:"gpt-5",displayName:"GPT-5",logoURL:"/images/modules/marketplace/models/families/openai.svg",upsellModel:!0,preview:!0,billing:{multiplier:1}},{id:"claude-3-7-thinking-upgrade",displayName:"Claude Sonnet 3.7 Thinking",logoURL:"/images/modules/marketplace/models/families/anthropic.svg",upsellModel:!0,billing:{multiplier:10}},{id:"claude-opus-4-upgrade",displayName:"Claude Opus 4",logoURL:"/images/modules/marketplace/models/families/anthropic.svg",upsellModel:!0,billing:{multiplier:10}}];try{C.displayName||(C.displayName="ModelPicker")}catch{}try{O.displayName||(O.displayName="RetryButtonGroup")}catch{}try{(o=RetryButtonGroupWithRef).displayName||(o.displayName="RetryButtonGroupWithRef")}catch{}try{D.displayName||(D.displayName="ModelPickerDesign")}catch{}try{q.displayName||(q.displayName="CustomModelActionListGroups")}catch{}try{T.displayName||(T.displayName="ModelPickerFooter")}catch{}try{U.displayName||(U.displayName="RetryListItem")}catch{}try{B.displayName||(B.displayName="ModelListItem")}catch{}try{S.displayName||(S.displayName="NewConversationConfirmationDialog")}catch{}try{G.displayName||(G.displayName="ModelPolicyConfirmationDialog")}catch{}try{Y.displayName||(Y.displayName="ModelVendorIcon")}catch{}},76787:(e,i,l)=>{l.d(i,{G:()=>c,L:()=>u});var o=l(11561);let a=l.p+"anthropic-black-2a433f413435.svg",t=l.p+"anthropic-white-e8b408a1ef75.svg",s=l.p+"azureai-9e78dba51a2a.svg",r=l.p+"openai-black-58397e7d4544.svg",n=l.p+"openai-white-b5b2b7960b82.svg",d=l.p+"xai-black-0bfd23792e19.svg",m=l.p+"xai-white-2a05e51396d1.svg",c=[{key:"openai",name:"OpenAI",logo:{light:r,dark:n}},{key:"azureai",name:"Azure AI",logo:{light:s,dark:void 0}},{key:"anthropic",name:"Anthropic",logo:{light:a,dark:t}},{key:"googleaistudio",name:"Google AI Studio",logo:{light:l.p+"google-black-8e35d6872f61.svg",dark:l.p+"google-white-dadceec3a30a.svg"}},{key:"xai",name:"xAI",logo:{light:d,dark:m}}];function u(e){let i=c.find(i=>i.key===e);return(0,o.A)(i,`Provider with key "${e}" not found`),i}}}]); //# sourceMappingURL=packages_copilot-chat_components_ModelPicker_tsx-packages_copilot-byok_providers_assets_anthr-76f86b-cc8cb3450df8.js.map